package com.fuxi.cloud.desreport.render.a;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.fuxi.cloud.common.constant.ExpConstant;
import com.fuxi.cloud.desreport.model.RenderInfo;
import com.fuxi.cloud.desreport.model.ReportDbInfo;
import com.fuxi.cloud.desreport.render.handler.data.RecursionHandler;
import com.fuxi.cloud.desreport.render.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * a
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */
@Component("tableDynamicRenderStrategy")
public class b extends d {
    private static final Logger f = LoggerFactory.getLogger(b.class);
    private List<String> g;
    private int h;
    private Map<String, Object> i;
    private Map<String, List<String>> j;
    public int a = 0;
    public List<String> b = new ArrayList();
    public List<String> c = new ArrayList();
    public List<Integer> d = new ArrayList();
    public List<Integer> e = new ArrayList();
    private Map<String, List<Integer>> k;

    public b() {
    }

    @Override
    public boolean support(JSONObject row) {
        String var2 = row.toString();
        return var2.indexOf("dynamic(") != -1 || var2.indexOf("groupRight(") != -1;
    }

    @Override
    public JSONObject beforeRenderRows(RenderInfo renderInfo, JSONObject rows) {
        List var3 = renderInfo.getGroupRightColumn();
        if (ObjectUtil.isNotEmpty(var3)) {
            RenderUtil.b(rows, (var1, var2) -> {
                String var4 = RegexMatches.a(var2, 2).replace("groupRight(", "").replace(")", "");
                renderInfo.addEachRow(var4, var1);
                return var4;
            }, new String[]{"groupRight("});
        }

        return rows;
    }

    @Override
    public JSONObject beforeRenderRow(RenderInfo renderInfo, JSONObject rows, JSONObject currentRow, Integer rowIndex) {
        this.g = RenderUtil.g(currentRow);
        f.debug("动态列", this.g);
        return RenderUtil.a(currentRow, (var0, var1) -> {
            return var1.replace("dynamic(", "").replace("group(", "").replace(")", "");
        }, new String[]{"group(", "dynamic("});
    }

    @Override
    public Object getData(RenderInfo renderInfo, ReportDbInfo reportDbInfo) {
        this.j = new HashMap();
        this.k = new TreeMap();
        List var3 = renderInfo.getGroupRightColumn();
        List var4 = renderInfo.getGroupUpColumn();
        List var5 = reportDbInfo.getList();

        com.fuxi.cloud.desreport.render.b.b var7;
        for(Iterator var6 = var4.iterator(); var6.hasNext(); var5 = RenderUtil.a(var5, var7.getColumn())) {
            var7 = (com.fuxi.cloud.desreport.render.b.b)var6.next();
        }

        ArrayList var17 = new ArrayList();
        var17.addAll(var4);
        Collections.reverse(var17);
        if (ObjectUtil.isEmpty(var17)) {
            var17.addAll(var3);
        }

        Map var18 = RenderUtil.a(var5, var17);
        final LinkedHashMap<String,List> var8 = new LinkedHashMap(5);
        this.i = var18;
        ArrayList var9 = new ArrayList();
        RenderUtil.a(var9, var18, new RecursionHandler() {
            @Override
            public List<JSONObject> doList(String key, List<JSONObject> list, JSONObject groupObj, String groupKey) {
                JSONArray var5 = ObjectUtil.isNotEmpty(var8.get(groupKey)) ? (JSONArray)var8.get(groupKey) : new JSONArray();
                Iterator var6 = list.iterator();

                while(var6.hasNext()) {
                    Object var7 = var6.next();
                    var5.add(var7);
                }

                var8.put(groupKey, var5);
                return list;
            }
        }, (JSONObject)null, "");
        Object var10 = new LinkedList();
        Object var11 = new LinkedList();
        JSONObject var12 = new JSONObject();
        if (ObjectUtil.isNotEmpty(var3)) {
            if (ObjectUtil.isEmpty(var4)) {
                new LinkedList();
                Iterator var14 = var3.iterator();

                while(var14.hasNext()) {
                    com.fuxi.cloud.desreport.render.b.b var15 = (com.fuxi.cloud.desreport.render.b.b)var14.next();
                    HashSet var16 = new HashSet();
                    var8.forEach((var21, var31x) -> {
                        String[] var41 = var21.split("_");
                        boolean var6 = false;
                        Iterator var71 = var31x.iterator();

                        while(var71.hasNext()) {
                            Object var81 = var71.next();
                            JSONObject var91 = (JSONObject)var81;
                            String var101 = var91.get(var15.getColumn()).toString();
                            if (ObjectUtil.isNotEmpty(var101)) {
                                var16.add(var101);
                            }
                        }

                    });
                }

                this.a(renderInfo, var12, var18, "");
                this.h = var12.size();
                renderInfo.setLen(var12.size());
                ((List)var10).add(var12);
                Collections.reverse((List)var10);
            } else {
                ReportDataUtil.a(var5, var3);
                var11 = this.a((RenderInfo)renderInfo, (Map)var8);
            }
        }

        Collections.reverse(var4);
        Iterator var13 = var4.iterator();

        while(var13.hasNext()) {
            com.fuxi.cloud.desreport.render.b.b var19 = (com.fuxi.cloud.desreport.render.b.b)var13.next();
            var10 = RenderUtil.b((List)var11, var19.getColumn());
            renderInfo.setLen(((JSONObject)((List)var11).get(0)).size());
        }

        return var10;
    }

    private String a(RenderInfo var1, String var2, Integer var3, String var4, JSONObject var5, JSONObject var6, JSONObject var7) {
        List var8 = var1.getGroupUpColumn();
        StringBuilder var9 = new StringBuilder();
        var9.append("{");
        var9.append(String.format("<#list list as %s>", var4));
        var9.append(String.format("\"${%s_index+%s}\":", var4, var3));
        JSONObject var10 = JSONObject.parseObject(var2, new Feature[]{Feature.OrderedField});
        JSONObject var11 = var10.getJSONObject("cells");
        JSONObject var12 = JSONObject.parseObject(var11.toString(), new Feature[]{Feature.OrderedField});
        JSONObject var13 = RenderUtil.j(var6);
        JSONObject var14 = null;
        if (ObjectUtil.isNotEmpty(var13)) {
            var14 = JSONObject.parseObject(var13.toString(), new Feature[]{Feature.OrderedField});
        }

        JSONObject var15 = null;
        JSONObject var16 = null;
        if (ObjectUtil.isNotEmpty(var7)) {
            var15 = var7.getJSONObject("cells");
            var16 = JSONObject.parseObject(var15.toString(), new Feature[]{Feature.OrderedField});
        }

        Boolean var17 = false;
        new JSONObject();
        new JSONObject();
        Integer var20 = 0;
        ArrayList var21 = new ArrayList();
        ArrayList var22 = new ArrayList();
        ArrayList var23 = new ArrayList();
        if (ObjectUtil.isNotEmpty(var8)) {
            label103:
            for(int var24 = 0; var24 < this.h; ++var24) {
                Iterator var25 = var11.entrySet().iterator();

                while(true) {
                    Integer var38;
                    Iterator var39;
                    JSONObject var40;
                    do {
                        do {
                            if (!var25.hasNext()) {
                                continue label103;
                            }

                            Map.Entry var26 = (Map.Entry)var25.next();
                            Integer var27 = Integer.parseInt(var26.getKey().toString());
                            JSONObject var28 = (JSONObject)var26.getValue();
                            String var29 = var28.getString("text");
                            String var30 = RegexMatches.a(var29, 2);
                            if (ObjectUtil.isNotEmpty(var30) && this.g.contains(var30)) {
                                var17 = true;
                                if (var24 == 0) {
                                    JSONObject var31 = (JSONObject)var12.get(var27);
                                    var31.put("text", this.a((String)var29, (Object)0));
                                } else {
                                    var38 = this.g.size() * var24 + var27;
                                    JSONObject var32 = new JSONObject();
                                    var32.putAll(var28);
                                    String var33 = var32.getString("text");
                                    var33 = this.a((String)var33, (Object)var24);
                                    var32.put("text", var33);
                                    JSONObject var34 = var12.getJSONObject(var38.toString());
                                    if (ObjectUtil.isNotEmpty(var34)) {
                                        var21.add(var34);
                                    }

                                    var12.put(var38.toString(), var32);
                                    JSONObject var35;
                                    JSONObject var36;
                                    JSONObject var37;
                                    if (ObjectUtil.isNotEmpty(var13)) {
                                        var35 = var13.getJSONObject(var27.toString());
                                        if (ObjectUtil.isNotEmpty(var35)) {
                                            var36 = JSONObject.parseObject(var35.toString());
                                            var37 = var13.getJSONObject(var38.toString());
                                            if (ObjectUtil.isNotEmpty(var37)) {
                                                var22.add(var37);
                                            }

                                            var13.put(var38.toString(), var36);
                                        }
                                    }

                                    if (ObjectUtil.isNotEmpty(var15)) {
                                        var35 = var15.getJSONObject(var27.toString());
                                        if (ObjectUtil.isNotEmpty(var35)) {
                                            var36 = JSONObject.parseObject(var35.toString());
                                            var37 = var15.getJSONObject(var38.toString());
                                            if (ObjectUtil.isNotEmpty(var37)) {
                                                var23.add(var37);
                                            }

                                            RenderUtil.a(var36, var38);
                                            var15.put(var38.toString(), var36);
                                        }
                                    }

                                    var20 = var38;
                                }
                            }
                        } while(var24 != this.h - 1);

                        if (ObjectUtil.isNotEmpty(var21)) {
                            var38 = var20 + 1;

                            for(var39 = var21.iterator(); var39.hasNext(); var38 = var38 + 1) {
                                var40 = (JSONObject)var39.next();
                                var12.put(var38.toString(), var40);
                            }
                        }

                        if (ObjectUtil.isNotEmpty(var22)) {
                            var38 = var20 + 1;

                            for(var39 = var22.iterator(); var39.hasNext(); var38 = var38 + 1) {
                                var40 = (JSONObject)var39.next();
                                var13.put(var38.toString(), var40);
                            }
                        }
                    } while(!ObjectUtil.isNotEmpty(var23));

                    var38 = var20 + 1;

                    for(var39 = var23.iterator(); var39.hasNext(); var38 = var38 + 1) {
                        var40 = (JSONObject)var39.next();
                        var15.put(var38.toString(), var40);
                    }
                }
            }
        } else {
            this.a = 0;
            this.a(var1, var11, var12, var13, var15, this.i);
        }

        var10.put("cells", var12);
        var9.append(var10.toString());
        var9.append(String.format("<#if %s_has_next>,</#if>", var4));
        var9.append("</#list>");
        var9.append("}");
        return var9.toString();
    }

    private String a(String var1, Object var2) {
        List var3 = RegexMatches.g(var1);
        Boolean var4 = RenderUtil.b(var1, ExpConstant.FREEMARKER_FUNCTION);
        if (var4) {
            String var5;
            if (ObjectUtil.isNotEmpty(var3) && var3.size() > 1) {
                var5 = RegexMatches.a(var1, 1);
                int var6 = 0;
                String var7 = "";

                for(Iterator var8 = var3.iterator(); var8.hasNext(); ++var6) {
                    String var9 = (String)var8.next();
                    if (var6 == 0) {
                        var7 = String.format(var9 + "%s?number", var2);
                    } else {
                        var7 = String.format(var5 + "." + var9 + "%s?number", var2);
                    }

                    var1 = var1.replace(var9, var7);
                }
            } else {
                var5 = RegexMatches.a(var1, 2);
                var1 = var1.replace(var5, var5 + var2);
            }
        }

        var1 = this.a(var1, var2.toString());
        return var1;
    }

    private String a(String var1, String var2) {
        Boolean var3 = RenderUtil.a(var1, ExpConstant.FREEMARKER_FUNCTION);
        if (var3) {
            String var4 = RegexMatches.a(var1, 1);
            String var5 = RegexMatches.a(var1, 2);
            List var6 = RegexMatches.d(var5);
            if (ObjectUtil.isNotEmpty(var6)) {
                String var7 = (String)var6.get(1);
                String var8 = (String)var6.get(2);
                if (ObjectUtil.isNotEmpty(var8)) {
                    String[] var9 = var8.split(",");
                    String[] var10 = var9[2].split(",");
                    String var11 = "";
                    int var12 = 0;
                    String[] var13 = var10;
                    int var14 = var10.length;

                    for(int var15 = 0; var15 < var14; ++var15) {
                        String var16 = var13[var15];
                        var11 = var11 + var16.replace("'", "") + var2;
                        ++var12;
                        if (var12 < var10.length) {
                            var11 = var11 + ",";
                        }
                    }

                    var1 = String.format("${jeecg.%s(%s,%s,'%s')}", var7, var9[0], var9[1], var11);
                    f.debug("单元格公式：" + var1);
                }
            }
        }

        return var1;
    }

    private void a(JSONObject var1, Integer var2, JSONObject var3) {
        Iterator var4 = var1.entrySet().iterator();

        while(var4.hasNext()) {
            Map.Entry var5 = (Map.Entry)var4.next();
            Integer var6 = Integer.parseInt(var5.getKey().toString());
            if (var6 > var2) {
                Integer var7 = var6 + 1;
                var1.put(var7.toString(), var5.getValue());
            }
        }

        var1.put(var2.toString(), var3);
    }

    private void b(JSONObject var1, Integer var2, JSONObject var3) {
        Iterator var4 = var1.entrySet().iterator();

        while(var4.hasNext()) {
            Map.Entry var5 = (Map.Entry)var4.next();
            Integer var6 = Integer.parseInt(var5.getKey().toString());
            if (var6 > var2) {
                Integer var7 = var6 + 1;
                var1.put(var7.toString(), var5.getValue());
            }
        }

        var1.put(var2.toString(), var3);
    }

    private void b(RenderInfo var1, JSONObject var2) {
        ArrayList var3 = new ArrayList();
        if (ObjectUtil.isNotEmpty(this.j)) {
            Integer var4 = 0;
            String var5 = "";
            Map var6 = var1.getEachRowObj();
            List var7 = var1.getGroupRightColumn();

            for(Iterator var8 = var6.entrySet().iterator(); var8.hasNext(); var4 = var4 + 1) {
                Map.Entry var9 = (Map.Entry)var8.next();
                Object var10 = var9.getKey();
                Integer var11 = 0;
                int var12 = 0;
                JSONObject var13 = null;
                Integer var14 = 0;
                JSONObject var15 = (JSONObject)var9.getValue();
                JSONObject var16 = var15.getJSONObject("cells");
                JSONObject var17 = new JSONObject();
                Iterator var18 = var16.entrySet().iterator();

                String var21;
                while(var18.hasNext()) {
                    Map.Entry var19 = (Map.Entry)var18.next();
                    JSONObject var20 = (JSONObject)var19.getValue();
                    var21 = var20.getString("text");
                    Object var22 = var19.getKey();
                    if (ObjectUtil.isNotEmpty(var21)) {
                        var17.put(var22.toString(), var20);
                    }
                }

                Object var36 = new ArrayList();
                new ArrayList();
                int var37 = this.g.size();
                var21 = RenderUtil.i(var17);
                String var38 = "";
                if (ObjectUtil.isNotEmpty(var21)) {
                    var36 = ((com.fuxi.cloud.desreport.render.b.b)var7.get(var4)).getValues();
                    List var10000 = (List)this.k.get(var4.toString());
                    var38 = ((com.fuxi.cloud.desreport.render.b.b)var7.get(var4)).getSuffixText();
                    var5 = ((com.fuxi.cloud.desreport.render.b.b)var7.get(var4)).getRowKey();
                }

                Integer var23 = 0;
                Integer var24 = 0;

                for(int var25 = 0; var25 < ((List)var36).size(); ++var25) {
                    Integer var26 = 1;

                    for(int var27 = var4; var27 < var6.size(); ++var27) {
                        List var28 = ((com.fuxi.cloud.desreport.render.b.b)var7.get(var27)).getChildSize();
                        if (ObjectUtil.isNotEmpty(var28)) {
                            var26 = var26 * (Integer)var28.get(var25);
                        } else if (this.g.size() > 1) {
                            var26 = var26 * this.g.size();
                        }
                    }

                    String var39 = "";
                    Iterator var40 = var17.entrySet().iterator();

                    JSONObject var30;
                    while(var40.hasNext()) {
                        Map.Entry var29 = (Map.Entry)var40.next();
                        var39 = var29.getKey().toString();
                        var30 = (JSONObject)var29.getValue();
                        Object var31 = var30.get("merge");
                        String var32 = var30.getString("direction");
                        String var33 = var30.getString("text");
                        if (!ObjectUtil.isEmpty(var33)) {
                            JSONArray var34;
                            if (ObjectUtil.isEmpty(var31) && ObjectUtil.isNotEmpty(var32)) {
                                var34 = new JSONArray();
                                var34.set(0, 0);
                                var34.set(1, 0);
                                var30.put("merge", var34);
                                var31 = var30.get("merge");
                            }

                            if (ObjectUtil.isNotEmpty(var31)) {
                                var34 = (JSONArray)var31;
                                if (this.k.size() == 0) {
                                    ;
                                }

                                if (ReportUtil.a(var33, var1.getGroupRightColumn())) {
                                    var30.put("text", (String)((List)var36).get(var25) + var38);
                                    var34.set(1, var26 - 1);
                                    if (var12 == 0) {
                                        var13 = var30;
                                        var11 = (Integer)var34.get(1);
                                        var14 = Integer.parseInt(var39);
                                        var23 = var14;
                                    }
                                }
                            }
                        }
                    }

                    if (var12 > 0) {
                        JSONObject var41 = new JSONObject();
                        if (ObjectUtil.isNotEmpty(var13)) {
                            var41.putAll(var13);
                            JSONArray var43 = new JSONArray();
                            if (var26 > 1) {
                                var43.set(0, 0);
                                var43.set(1, var26 - 1);
                                var41.put("merge", var43);
                                var23 = var23 + var24;
                            } else {
                                var23 = var23 + 1;
                            }

                            var41.put("text", (String)((List)var36).get(var25) + var38);
                            var30 = var17.getJSONObject(var23.toString());
                            if (ObjectUtil.isNotEmpty(var30)) {
                                var3.add(var30);
                            }

                            try {
                                this.a(var17, var23, var41);
                            } catch (Exception var35) {
                                var35.printStackTrace();
                            }
                        }
                    }

                    ++var12;
                    if (var12 == ((List)var36).size() && ObjectUtil.isNotEmpty(var3)) {
                        Integer var42 = var23 + var11 + 1;

                        for(Iterator var44 = var3.iterator(); var44.hasNext(); var42 = var42 + var23) {
                            var30 = (JSONObject)var44.next();
                            var17.put(var42.toString(), var30);
                        }
                    }

                    var24 = var26;
                }

                var15.put("cells", var17);
                this.a((RenderInfo)var1, (JSONObject)var17, (Object)var5);
            }
        }

    }

    private void a(RenderInfo var1, JSONObject var2, Object var3) {
        HashMap var4 = new HashMap();
        if (ObjectUtil.isNotEmpty(var2)) {
            Iterator var5 = var2.entrySet().iterator();

            while(var5.hasNext()) {
                Map.Entry var6 = (Map.Entry)var5.next();
                Object var7 = var6.getKey();
                JSONObject var8 = (JSONObject)var6.getValue();
                Object var9 = var8.get("merge");
                JSONObject var10 = new JSONObject();
                if (ObjectUtil.isNotEmpty(var9)) {
                    var10.put("merge", var9);
                    var10.put("cellIndex", var7);
                    var10.put("rowIndex", var3);
                    var4.put(var7.toString(), var10);
                }
            }

            JSONArray var11 = RenderUtil.b(var4);
            var1.addMerges(var11);
        }

    }

    @Override
    public JSONObject afterRenderRow(RenderInfo renderInfo, JSONObject row, JSONObject dynamicRowObj, Integer dynamicRowEndIndex) {
        this.b = new ArrayList();
        this.c = new ArrayList();
        this.d = new ArrayList();
        this.e = new ArrayList();
        this.k = new LinkedHashMap();
        return this.a((RenderInfo)renderInfo, (JSONObject)dynamicRowObj);
    }

    @Override
    public JSONObject render(RenderInfo renderInfo, JSONObject rows, JSONObject currentRow, Integer rowIndex, Integer dynamicRowEndIndex) {
        Map var6 = renderInfo.getReport().getDataList();
        String var7 = currentRow.toString();
        HashMap var8 = new HashMap(5);
        JSONObject var9 = (JSONObject)rows.get(rowIndex - 1);
        JSONObject var10 = (JSONObject)rows.get(rowIndex + 1);
        String var11 = this.getDataSetKey(var7);
        if (ObjectUtil.isNotEmpty(var11)) {
            ReportDbInfo var12 = (ReportDbInfo)var6.get(var11);
            if (ObjectUtil.isNotEmpty(var12)) {
                List var13 = (List)this.getData(renderInfo, var12);
                var8.put("list", var13);
                String var14 = this.a(renderInfo, currentRow.toString(), dynamicRowEndIndex, var11, currentRow, var9, var10);
                String var15 = FreeMarkerUtils.a(var14, var8);
                JSONObject var16 = JSONObject.parseObject(var15, new Feature[]{Feature.OrderedField});
                this.b(renderInfo, rows);
                this.afterRenderRow(renderInfo, currentRow, var16, dynamicRowEndIndex);
                return var16;
            } else {
                return currentRow;
            }
        } else {
            return null;
        }
    }

    private List<JSONObject> a(RenderInfo var1, Map<String, JSONArray> var2) {
        List var3 = var1.getGroupUpColumn();
        Collections.reverse(var3);
        HashMap var4 = new HashMap();
        LinkedHashSet var5 = new LinkedHashSet();
        List var6 = var1.getGroupRightColumn();
        Iterator var7 = var6.iterator();

        while(var7.hasNext()) {
            com.fuxi.cloud.desreport.render.b.b var8 = (com.fuxi.cloud.desreport.render.b.b)var7.next();
            ArrayList var9 = new ArrayList();
            var2.forEach((var6x, var7x) -> {
                String[] var8x = var6x.split("_");
                JSONObject var9x = (JSONObject)var4.get(var6x);
                if (ObjectUtil.isEmpty(var9x)) {
                    var9x = new JSONObject();
                }

                for(int var10 = 0; var10 < var3.size(); ++var10) {
                    var9x.put(((com.fuxi.cloud.desreport.render.b.b)var3.get(var10)).getColumn(), var8x[var10]);
                }

                int var11 = 0;

                for(Iterator var12 = var7x.iterator(); var12.hasNext(); ++var11) {
                    Object var13 = var12.next();
                    JSONObject var14 = (JSONObject)var13;
                    String var15 = var14.get(var8.getColumn()).toString();
                    if (ObjectUtil.isNotEmpty(var15)) {
                        var9.add(var15);
                    }

                    Iterator var16 = var14.entrySet().iterator();

                    while(var16.hasNext()) {
                        Map.Entry var17 = (Map.Entry)var16.next();
                        String var18 = var17.getKey().toString();
                        if (!var3.contains(var18)) {
                            var9x.put(var17.getKey().toString() + var11, var17.getValue());
                        }
                    }
                }

                this.h = var11;
                var4.put(var6x, var9x);
                var5.add(var9x);
            });
            this.j.put(var8.getColumn(), new ArrayList(new LinkedHashSet(var9)));
        }

        return new ArrayList(var5);
    }

    private void a(RenderInfo var1, JSONObject var2, Map<String, Object> var3, String var4) {
        int var5 = 0;

        for(Iterator var6 = var3.entrySet().iterator(); var6.hasNext(); ++var5) {
            Map.Entry var7 = (Map.Entry)var6.next();
            String var8 = (String)var7.getKey();
            Object var9 = var7.getValue();
            if (var9 instanceof ArrayList) {
                List var11 = (List)var9;
            }

            if (var9 instanceof HashMap) {
                this.a(var1, var5, var2, (Map)var9, var8);
            }
        }

    }

    private void a(RenderInfo var1, int var2, JSONObject var3, Map<String, Object> var4, String var5) {
        int var6 = 0;
        Iterator var7 = var4.entrySet().iterator();

        while(var7.hasNext()) {
            Map.Entry var8 = (Map.Entry)var7.next();
            String var9 = (String)var8.getKey();
            Object var10 = var8.getValue();
            System.out.println(var10);
            if (var10 instanceof ArrayList) {
                List var12 = (List)var10;
                JSONObject var13 = (JSONObject)var12.get(0);
                Iterator var14 = var13.entrySet().iterator();

                while(var14.hasNext()) {
                    Map.Entry var15 = (Map.Entry)var14.next();
                    String var16 = var15.getKey().toString();
                    if (!ReportUtil.a(var16, var1.getGroupRightColumn())) {
                        var3.put(var16 + "_" + var2 + "_" + var6, var15.getValue());
                    }
                }

                ++var6;
            }

            if (var10 instanceof HashMap) {
                Map var11 = (Map)var10;
                this.a(var1, var2, var6, var3, var11, var9);
                ++var6;
            }
        }

    }

    private void a(RenderInfo var1, int var2, int var3, JSONObject var4, Map<String, Object> var5, String var6) {
        int var7 = 0;
        Iterator var8 = var5.entrySet().iterator();

        while(true) {
            Object var11;
            do {
                if (!var8.hasNext()) {
                    return;
                }

                Map.Entry var9 = (Map.Entry)var8.next();
                String var10 = (String)var9.getKey();
                var11 = var9.getValue();
                System.out.println(var11);
            } while(!(var11 instanceof ArrayList));

            List var13 = (List)var11;
            JSONObject var14 = (JSONObject)var13.get(0);
            Iterator var15 = var14.entrySet().iterator();

            while(var15.hasNext()) {
                Map.Entry var16 = (Map.Entry)var15.next();
                String var17 = var16.getKey().toString();
                if (!ReportUtil.a(var17, var1.getGroupRightColumn())) {
                    var4.put(var17 + "_" + var2 + "_" + var3 + "_" + var7, var16.getValue());
                }
            }

            ++var7;
        }
    }

    private void a(RenderInfo var1, JSONObject var2, JSONObject var3, JSONObject var4, JSONObject var5, Map<String, Object> var6) {
        int var7 = 0;
        LinkedList var8 = new LinkedList();
        LinkedList var9 = new LinkedList();
        com.fuxi.cloud.desreport.render.b.b var10 = (com.fuxi.cloud.desreport.render.b.b)var1.getGroupRightColumn().get(0);

        for(Iterator var11 = var6.entrySet().iterator(); var11.hasNext(); ++var7) {
            Map.Entry var12 = (Map.Entry)var11.next();
            String var13 = (String)var12.getKey();
            Object var14 = var12.getValue();
            var8.add(var13);
            this.j.put(var10.getColumn(), var8);
            if (var14 instanceof HashMap) {
                var9.add(((HashMap)var14).size());
                this.k.put("0", var9);
                var10.setChildSize(var9);
                this.a(var1, var7, var2, var3, var4, var5, (Map)var14);
            }
        }

        var10.setValues(var8);
        var10.setChildSize(var9);
    }

    private void a(RenderInfo var1, int var2, JSONObject var3, JSONObject var4, JSONObject var5, JSONObject var6, Map<String, Object> var7) {
        int var8 = 0;
        List var9 = var1.getGroupRightColumn();

        for(Iterator var10 = var7.entrySet().iterator(); var10.hasNext(); ++var8) {
            Map.Entry var11 = (Map.Entry)var10.next();
            if (var9.size() > 1) {
                String var12 = (String)var11.getKey();
                this.b.add(var12.toString());
                this.j.put(((com.fuxi.cloud.desreport.render.b.b)var9.get(1)).getColumn(), this.b);
                ((com.fuxi.cloud.desreport.render.b.b)var1.getGroupRightColumn().get(1)).a(var12);
            }

            Object var13 = var11.getValue();
            if (var13 instanceof ArrayList) {
                if (var9.size() > 1) {
                    this.d.add(1 * this.g.size());
                    this.k.put("1", this.d);
                    ((com.fuxi.cloud.desreport.render.b.b)var1.getGroupRightColumn().get(1)).a(1 * this.g.size());
                }

                this.a(var3, var4, var5, var6, var2 + "_" + var8);
            }

            if (var13 instanceof HashMap) {
                this.d.add(((HashMap)var13).size());
                this.k.put("1", this.d);
                ((com.fuxi.cloud.desreport.render.b.b)var1.getGroupRightColumn().get(1)).a(((HashMap)var13).size());
                this.a(var1, var2, var8, var3, var4, var5, var6, (Map)var13);
            }
        }

    }

    private void a(RenderInfo var1, int var2, int var3, JSONObject var4, JSONObject var5, JSONObject var6, JSONObject var7, Map<String, Object> var8) {
        int var9 = 0;
        List var10 = var1.getGroupRightColumn();

        for(Iterator var11 = var8.entrySet().iterator(); var11.hasNext(); ++var9) {
            Map.Entry var12 = (Map.Entry)var11.next();
            if (var10.size() > 2) {
                String var13 = (String)var12.getKey();
                this.c.add(var13.toString());
                this.j.put(((com.fuxi.cloud.desreport.render.b.b)var10.get(2)).getColumn(), this.c);
                ((com.fuxi.cloud.desreport.render.b.b)var1.getGroupRightColumn().get(2)).setValues(this.c);
            }

            Object var14 = var12.getValue();
            this.e.add(1 * this.g.size());
            this.k.put("2", this.e);
            ((com.fuxi.cloud.desreport.render.b.b)var1.getGroupRightColumn().get(2)).setChildSize(this.e);
            System.out.println(var14);
            if (var14 instanceof ArrayList) {
                this.a(var4, var5, var6, var7, var2 + "_" + var3 + "_" + var9);
            }
        }

    }

    private void a(JSONObject var1, JSONObject var2, JSONObject var3, JSONObject var4, String var5) {
        Iterator var6 = var1.entrySet().iterator();

        while(var6.hasNext()) {
            Map.Entry var7 = (Map.Entry)var6.next();
            Integer var8 = Integer.parseInt(var7.getKey().toString());
            if (var8 > this.a) {
                this.a = var8;
            }

            JSONObject var9 = (JSONObject)var7.getValue();
            String var10 = var9.getString("text");
            String var11 = RegexMatches.a(var10, 2);
            if (ObjectUtil.isNotEmpty(var11) && this.g.contains(var11)) {
                Integer var12 = this.a;
                JSONObject var13 = new JSONObject();
                var13.putAll(var9);
                String var14 = var13.getString("text");
                var14 = this.a((String)var14, (Object)("_" + var5));
                var13.put("text", var14);
                var2.put(var12.toString(), var13);
                JSONObject var15;
                JSONObject var16;
                if (ObjectUtil.isNotEmpty(var3)) {
                    var15 = var3.getJSONObject(var8.toString());
                    if (ObjectUtil.isNotEmpty(var15)) {
                        var16 = JSONObject.parseObject(var15.toString());
                        var3.getJSONObject(var12.toString());
                        var3.put(var12.toString(), var16);
                    }
                }

                if (ObjectUtil.isNotEmpty(var4)) {
                    var15 = var4.getJSONObject(var8.toString());
                    if (ObjectUtil.isNotEmpty(var15)) {
                        var16 = JSONObject.parseObject(var15.toString());
                        var4.getJSONObject(var12.toString());
                        RenderUtil.a(var16, var12);
                        var4.put(var12.toString(), var16);
                    }
                }

                ++this.a;
            }
        }

    }
}

